define(function(require, exports, module) {
    require('form');
    exports.init = function(config) {
        $('#js-register-form').on('submit', function() {
            $(this).ajaxSubmit({
                url: '/Ajax/Passport/register?stmp=' + new Date().toDateString(),
                type: 'post',
                dataType: 'json',
                success: function(d) {
                    if (d.error) {
                        $('#error').html(d.data);
                    } else {
                        $('#error').html('您已注册成功，3秒后跳转登录业，点击马上跳转<a href="/login.html?fromurl=' + config.fromUrl + '">登录</a>');
                        setTimeout(function() {
                            window.location.href = '/login.html?fromurl=' + config.fromUrl;
                        }, 3000);
                    }
                }
            });
            return false;
        });
    }
});